#include <faker/engine/ui/EntityEditor.h>

void Faker::Engine::UI::EntityEditor::Instance()
{
    if (mOpen)
    {
        if (ImGui::Begin(mTitle.c_str(), &mOpen))
        {
            EditEntity();
        }
        ImGui::End();
    }
}

void Faker::Engine::UI::EntityEditor::HandleSignal()
{
    auto &sg = Faker::Engine::UI::StateBuffer::signal;

    if (sg._shouldChangeEntity)
    {
        FK_LOGD("changed value");
        this->m_Inst = sg._entityValue;
        sg._shouldChangeEntity = false;
    }
}

void Faker::Engine::UI::EntityEditor::EditEntity()
{
    if (!m_Inst.HasComponent<Faker::Basic::Uid::Inst>())
    {
        return;
    }
    // auto &info = m_Inst.GetComponent<Faker::Basic::Info::Inst>();
    // ImGui::Text("name %s", info.m_Name.c_str());
    // auto& simpleColorMaterial=m_Inst.GetComponent<Faker::Render::Material::SimpleColor::Inst>();
    // ImGui::ColorEdit4("color", &simpleColorMaterial.mColor.x);
    m_BasicEditor.Edit(m_Inst);
    m_RenderEditor.Edit(m_Inst);

}